﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KC.DataAccess.Hub;

public partial class Page : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
		if (Request.QueryString["title"] == null || string.IsNullOrEmpty(Request.QueryString["title"]))
		{
			lblBody.Text = "Please select a product.";
			return;
		}
		string title = Server.UrlEncode(Request.QueryString["Title"].ToLower().Trim());

		var pages = from p in Master.dcHub.Pages
					where p.FriendlyName.ToLower().Trim() == title
					select p;
		if (pages.Count() == 0) {
			lblBody.Text = "No products matched your query.";
			return;
		}

		KC.DataAccess.Hub.Page page = pages.First();
		Title = HttpUtility.HtmlEncode(page.Title);
		hlTitle.Text = HttpUtility.HtmlEncode(page.Title);
		hlTitle.NavigateUrl = "http://www.kconnolly.net/hub/" + page.FriendlyName;
		lblBody.Text = KC.Business.Text.Encoding.BlogDecodeForRendering(page.Body);
    }
}